// 云函数入口文件
const cloud = require('wx-server-sdk');
cloud.init();
const db = cloud.database();

// 云函数入口函数
exports.main = async (event, context) => {
  const { username, password } = event;
  
  try {
    const result = await db.collection('zyzl_admin')
      .where({
        _id: 'qe8WrqKOzjgkPZSU',
        username: username,
        password: password
      })
      .get();

    if (result.data.length > 0) {
      return { success: true };
    } else {
      return { success: false };
    }
  } catch (err) {
    console.error(err);
    return { success: false, errMsg: err.message };
  }
};
